package lk.icta.core.entity;

import lk.icta.common.entity.BaseEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * @author Kusal Samarakoon
 */

@Entity
@Table(schema = "ELAND_RAIL")
public class LeaseDetail extends BaseEntity {


    @Column(nullable = false)
    private String leaseNo;

    @Column(nullable = true)
    private String lotNumber;

    @Column(nullable = false)
    private int validityPeriod;

    @Column(nullable = true)
    private String leasePeriodInWord;

    @Column(nullable = true)
    @Temporal(value = TemporalType.DATE)
    private Date leaseStartingDate;

    @Column(nullable = true)
    @Temporal(value = TemporalType.DATE)
    private Date leaseExpiringDate;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double annualRental;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double annualTax;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double arrearsAmount;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double arrearsTax;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double paidAmount;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double paidTax;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double totalPayable;

    @Column(nullable = true, columnDefinition="Decimal(15,2) default '0.00'")
    private double totalTaxPayable;

    public String getLeaseNo() {
        return leaseNo;
    }

    public void setLeaseNo(String leaseNo) {
        this.leaseNo = leaseNo;
    }

    public int getValidityPeriod() {
        return validityPeriod;
    }

    public void setValidityPeriod(int validityPeriod) {
        this.validityPeriod = validityPeriod;
    }

    public String getLeasePeriodInWord() {
        return leasePeriodInWord;
    }

    public void setLeasePeriodInWord(String leasePeriodInWord) {
        this.leasePeriodInWord = leasePeriodInWord;
    }

    public Date getLeaseStartingDate() {
        return leaseStartingDate;
    }

    public void setLeaseStartingDate(Date leaseStartingDate) {
        this.leaseStartingDate = leaseStartingDate;
    }

    public Date getLeaseExpiringDate() {
        return leaseExpiringDate;
    }

    public void setLeaseExpiringDate(Date leaseExpiringDate) {
        this.leaseExpiringDate = leaseExpiringDate;
    }

    public double getAnnualRental() {
        return annualRental;
    }

    public void setAnnualRental(Double annualRental) {
        this.annualRental = annualRental;
    }

    public String getLotNumber() {
        return lotNumber;
    }

    public void setLotNumber(String lotNumber) {
        this.lotNumber = lotNumber;
    }

    public double getAnnualTax() {
        return annualTax;
    }

    public void setAnnualTax(Double annualTax) {
        this.annualTax = annualTax;
    }

    public double getArrearsAmount() {
        return arrearsAmount;
    }

    public void setArrearsAmount(Double arrearsAmount) {
        this.arrearsAmount = arrearsAmount;
    }

    public double getArrearsTax() {
        return arrearsTax;
    }

    public void setArrearsTax(Double arrearsTax) {
        this.arrearsTax = arrearsTax;
    }

    public double getPaidAmount() {
        return paidAmount;
    }

    public void setPaidAmount(Double paidAmount) {
        this.paidAmount = paidAmount;
    }

    public double getPaidTax() {
        return paidTax;
    }

    public void setPaidTax(Double paidTax) {
        this.paidTax = paidTax;
    }

    public double getTotalPayable() {
        return totalPayable;
    }

    public void setTotalPayable(Double totalPayable) {
        this.totalPayable = totalPayable;
    }

    public double getTotalTaxPayable() {
        return totalTaxPayable;
    }

    public void setTotalTaxPayable(Double totalTaxPayable) {
        this.totalTaxPayable = totalTaxPayable;
    }

    public void addArrears(double newRent) {
        this.arrearsAmount += newRent;
    }

    public void addArrearsTax(double newTax) {
        this.arrearsTax += newTax;
    }

    public void addPayable(double payable) {
        this.totalPayable += payable;
        this.arrearsAmount = this.totalPayable - this.paidAmount;
    }

    public void addTaxPayable(double tax) {
        this.totalTaxPayable += tax;
        this.arrearsTax = this.totalTaxPayable - this.paidTax;
    }

    public void addPayment(double paidAmount){
        this.paidAmount += paidAmount;
        this.arrearsAmount = this.totalPayable - this.paidAmount;
    }

    public void addTaxPayment(double paidTax){
        this.paidTax += paidTax;
        this.arrearsTax = this.totalTaxPayable - this.paidTax;
    }
}
